#include "graph_utils.h"
#include <gperftools/profiler.h>

DOCA_LOG_REGISTER(MAIN);

DEFINE_int32(batch_size, 1, "batch_size");
DEFINE_int32(feature_num, 1, "feature_num");
DEFINE_int32(ele_num, 1, "ele_num per feature");
#if defined(__aarch64__)
DEFINE_string(dag_filename, "/home/ubuntu/xeg/BenchBF3/rap/data/preprocess_ir.txt", "dag extract from");
#else
DEFINE_string(dag_filename, "/root/xeg/BenchBF3/rap/data/preprocess_ir.txt", "dag extract from");
#endif

DEFINE_int32(if_pipeline, 1,  "if using pipeline");

#if defined(__aarch64__)
DEFINE_string(dispatch_device_type, "arm", "which device to dispatch");
#else
DEFINE_string(dispatch_device_type, "cpu", "which device to dispatch");
#endif

DEFINE_int32(if_cross_device, 0, "if pipeline cross device");

int main(int argc, char **argv) {
    // ProfilerStart("cpu.prof");
    gflags::ParseCommandLineFlags(&argc, &argv, true);

    DAGBuilder & dagbuilder = DAGBuilder::Instance();

    device_type_t cur_device_type = device_type_t::DEVICE_CPU;
    if (FLAGS_dispatch_device_type == "arm") cur_device_type = device_type_t::DEVICE_ARM;

    if (FLAGS_if_pipeline != 1){
        LOG(INFO) << "sequence execute";
        dagbuilder.main(FLAGS_dag_filename, FLAGS_feature_num, FLAGS_batch_size, FLAGS_ele_num, cur_device_type);
    }
    else {
        LOG(INFO) << "using pipeline";
        dagbuilder.pipeline_main(FLAGS_dag_filename, FLAGS_feature_num, FLAGS_batch_size, FLAGS_ele_num, FLAGS_if_cross_device);
    }

    // ProfilerStop();
    
    return EXIT_SUCCESS;
}